<%= content_for :title, "Projects ##{@project.id}" %>
<%= turbo_stream_from @project, :events %>

<%= project_layout(@project) do %>
  <% if !@project.deployable? %>
    <div>
      <p class="text-gray-500">Please <%= link_to "add a service", project_services_path(@project), class: "link" %> before deploying.</p>
    </div>
  <% else %>
    <table class="table mt-2 rounded-box" id="order_table" data-component="table">
      <thead>
        <tr>
          <th>
            <span class="text-sm font-medium text-base-content/80">Commit</span>
          </th>
          <th>
            <span class="text-sm font-medium text-base-content/80">Sha</span>
          </th>
          <th>
            <span class="text-sm font-medium text-base-content/80">Status</span>
          </th>
          <th>
            <span class="text-sm font-medium text-base-content/80">Deployed At</span>
          </th>
          <th>
            <span class="text-sm font-medium text-base-content/80">User</span>
          </th>
          <th>
            <span class="text-sm font-medium text-base-content/80"></span>
          </th>
        </tr>
      </thead>
      <tbody id="events">
        <% if @events.empty? %>
          <tr id="no-events-message">
            <td colspan="7" class="text-gray-500">No deployments yet</td>
          </tr>
        <% else %>
          <% @events.each do |event| %>
            <%= render 'projects/deployments/event_row', project: @project, event: event %>
          <% end %>
        <% end %>
      </tbody>
    </table>

    <%= render 'shared/pagination', pagy: @pagy %>
  <% end %>
<% end %>